﻿using System;
using System.Collections.Generic;
using System.Web.UI;
using System.Web.UI.WebControls;
using Rabbit.Logic;

namespace RabbitShop.UI
{
    public partial class ProductList : System.Web.UI.Page
    {
        public List<Product> Products;
        protected void Page_Load(object sender, EventArgs e)
        {
            Products = GetProductList();
            productRepeater.DataSource = Products;
            productRepeater.DataBind();
        }

        private List<Product> GetProductList()
        {
            List<Product> products = RabbitUse.GetProductList(Db.Store);
            return products;
        }

        private int index = 1;
        protected void productRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (index % 3 == 0)
            {
                e.Item.Controls.Add(new LiteralControl("</tr><tr>"));
            }
            index++;
        }
    }
}